package za.ac.sun.cs.viz.distrib;

public class VizTreeNodeVersion implements Comparable<VizTreeNodeVersion> {

	private long timestamp;
	
	private final int id;
	
	private final long value;
	
	private final int activity;
	
	private VizNode activeVizNode = null;

	private VizNode inactiveVizNode = null;
	
	private final String name;

	public VizTreeNodeVersion(long timestamp, int id, long value, String name, int activity) {
		this.timestamp = timestamp;
		this.id = id;
		this.value = value;
		this.activity = activity;
		this.name = name;
	}

	public void setTimestamp(long timestamp) {
		this.timestamp = timestamp;
	}

	public long getTimeStamp() {
		return timestamp;
	}
	
	public long getValue() {
		return value;
	}

	public VizNode getVizNode(boolean isActive) {
		if (isActive) {
			if (activeVizNode == null) {
				String x = name + " " + value;
				activeVizNode = new VizNode(x, activity, id);
			}
			return activeVizNode;
		} else {
			if (inactiveVizNode == null) {
				String x = name + " " + value;
				inactiveVizNode = new VizNode(x, VizTreePane.INACTIVE, VizTreePane.NOONE);
			}
			return inactiveVizNode;
		}
	}

	@Override
	public int compareTo(VizTreeNodeVersion o) {
		return Long.compare(timestamp, o.timestamp);
	}

}
